<template>
  <div class="words">
    <div class="hotword">
      <span
        v-for="word in hotWords"
        :key="word.searchWord"
        @click="$emit('changekeyword', word.searchWord)"
        >{{ word.searchWord }}</span
      >
    </div>
    <div class="history">
      <!-- <ul>
        <li>{{ word.searchWord }}</li>
      </ul> -->
    </div>
  </div>
</template>
<script>
// var store = {
//   save(key, value) {
//     window.localStorage.setItem(key, JSON.stringify(value));
//   },
//   fetch(key) {
//     return JSON.parse(window.localStorage.getItem(key)) || [];
//   },
// };
// var searchWord = store.fetch("storeData");
export default {
  // beforeRouteEnter(){}
  data() {
    return {
      hotWords: [],
    //   searchWord,
    };
  },
//   watch: {
//     searchWord: {
//       handler: function () {
//         store.save("storeData", this.word.searchWord);
//       },
//       deep: true,
//     },
//   },
  created() {
    this.axios.get("/search/hot/detail").then((result) => {
      this.hotWords = result.data.slice(0, 10);
    });
  },
};
</script>
<style scoped lang="less">
.words {
  overflow: hidden;
  span {
    float: left;
    font-size: 14px;
    line-height: 16px;
    padding: 5px 10px;
    margin: 5px;
    border-radius: 14px;
    color: #535353;
    background-color: white;
  }
}
</style>